﻿using System;

namespace WhenNothingToDo
{
    class Program
    {
        static void Main(string[] args)
        {
            Fighter mike = new Fighter("Mike");
            Fighter jack = new Fighter("Jack");

            var randomForTraining = new Random();

            for (int i = 0; i < 10; i++) 
            {
                randomTrain(mike, randomForTraining.NextDouble());
                randomTrain(jack, randomForTraining.NextDouble());
            }

            Console.WriteLine();

            var randomForTurn = new Random();

            while (mike.isAlive() && jack.isAlive()) 
            {
                if (randomForTurn.NextDouble() > 0.49)
                {
                    jack.Hitted(mike.Hit());
                    if (jack.isAlive())
                    {
                        mike.Hitted(jack.Hit());
                    }
                }
                else
                {
                    mike.Hitted(jack.Hit());
                    if (mike.isAlive())
                    {
                        jack.Hitted(mike.Hit());
                    }
                }
            }

            Console.ReadLine();
        }

        private static void randomTrain(Fighter fighter,double rnd) 
        {
            if (rnd > 0.5)
            {
                fighter.TrainStrength();
            }
            else
            {
                fighter.TrainSpeed();
            }
        }
    }
}
